/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package grex.Data;

import grex.WekaModels.WekaPredictiveModel;
import grex.Options;
import java.util.Arrays;
import java.util.Hashtable;

/**
 *
 * @author RIK
 */
public class BootStrapArffTableModel extends ArffTableModel {

    WekaPredictiveModel model;
    private Hashtable<String, double[][]> bagTrainFolds = new Hashtable<String, double[][]>();
    private Hashtable<String, double[][]> outOfbagTrainFolds = new Hashtable<String, double[][]>();
    private Hashtable<String, double[][]> extractionValFolds = new Hashtable<String, double[][]>();
    private Hashtable<String, double[][]> extractionTestFolds = new Hashtable<String, double[][]>();
    private boolean useOracle = false;

    public BootStrapArffTableModel(ArffTableModel data) {
        super(data);
    }

    /*
     * public double[][] getTestFold(String fold) {
     *
     *
     * }
     *
     * public double[][] getValFold(String fold) {
     *
     * return data; }
     */
    //Should always be used to get a fold as lazy initzilation is used.

    @Override
    public double[][] getTrainFold(String fold) {
        double[][] bagData = bagTrainFolds.get(fold);
        if (bagData == null) {
            double[][] data = super.getTrainFold(fold);
            bagData = new double[data.length][data[0].length];
            int i = 0;
            while (i < data.length) {
                int rnd = Options.rnd.nextInt(data.length);
                bagData[i] = Arrays.copyOfRange(data[rnd], 0, data[rnd].length);
                i++;
            }
            bagTrainFolds.put(fold, bagData);
        }
        return bagData;
    }
}
